package Demo.demo6;

public class Account {
    private int  accountNumber; //账号
    private double balance;//余额

    public void deposit(double money){  //存钱
        this.balance=this.balance+money;
    }

    public double getBalance() {
        return balance;
    }

    public int getAccountNumber() {
        return accountNumber;
    }

    public void withdraw(double money) throws BankException{
        if (this.balance>=money){
            this.balance=this.balance=money;
        }else{
            double needs=money-this.balance;
            throw new BankException("余额不足",needs);
        }
    }

}
